<?php
include_once("inc/model.php");
  
class controller {

    public $model;
  
    public function __construct() {
		$this->model = new model();
	}

    public function start() {
		if (!isset($_GET['id'])) {
			// no special id is requested, show all
			if (!isset($_GET['p'])) {
				//no pages set
				$entries = $this->model->getallposts(1);
			} else {
				$entries = $this->model->getallposts($_GET['p']);
			}
			$pages = $this->model->pages();
			include 'views/all.php';
		} else {
			// show the requested id
			$entry = $this->model->getpost($_GET['id']);
			include 'views/single.php';
		}
	}
}

?> 